The gemara says that if one needs to relieve oneself he may not daven. The Rambam [Hil Tfila 4/10] implies that the reason is that one will not have proper kavana under such circumstances. So writes the Levush [92/1] explicitly.
The Tur [90 and 92] writes that the reason is that one must daven with a clean body. Just as the place of tfila must be clean so must the person davening. The Rema [92a] writes that there is a similar law regarding the learning of Torah that one may not say words of Torah if his body is not clean. [See Aruch Hashulchan 92/4]. This has nothing to do with the aforementioned explanation that one must have proper kavana because there is no law that one must have special kavana when learning Torah.
The Magen Avraham [92a] writes that the law that one's tfilla is an abomination if he davens while having to relieve himself and he must daven again is referring specifically to an instance where one must defecate [גדולים] but if he must merely urinate [קטנים] he need not daven again [בדיעבד].
However the Eliyahu Rabba writes that one must daven again even if he davened when having to urinate.
Apparently their dispute is with regards to why one may not daven when having to relieve himself. According to the Magen Avraham the reason is that one's body is unclean and therefore we can make a distinction between גדולים and קטנים. Only גדולים make one's body unclean enough to necessitate a repetition of the tfilla. The Eliyahu Rabba learns that the problem is a lack of kavana. This would apply equally to גדולים and קטנים.
גברות יצחק עמ' רעא-ערב