In his c.1900 dictionary Edward Dwelly explains it as "bu" (WOULD in English) thus:-
"ciod a b' àill leibh? what would you have? “b' àill leibh?” (a slovenly pronunciation of the last) is often used as an equivalent of I beg your pardon? when one speaker has not understood a remark made by another and wishes it repeated".
If you go to DUOLINGO TIPS (https://duome.eu/tips/en/gd) this is explained as an idiomatic anomaly i.e. although it looks wrong it's just the way it is said as a 'fixed phrase'. Here is the explanation copied from DUOLINGO TIPS:-
"B’ àill leibh
This term means "pardon". Use this for when you haven't understood what has been said. Although leibh is normally used as a polite form, here it is part of a set usage. You would use b’ àill leibh even with a child.
N.B. We have spelled b’ aill leibh without an accent in the course. As mistakes go, it is not the worst. The word, although spelled with an accent, is pronounced with a short vowel sound in modern Gaelic. We will correct this in iteration 2 of the course."