The prayer begins with Numbers 24:5, where Balaam, sent to curse the Israelites, is instead overcome with awe at God and the Israelites' houses of worship. Its first line of praise is a quote of Balaam's blessing and is thus the only prayer commonly used in Jewish services that was written by a non-Jew. The remainder of the text is derived from passages in Psalms relating to entering the house of worship and preparation for further prayer (Psalms 5:8; 26:8; 95:6; and 69:14). In this vein is the prayer recited by Jews upon entering the synagogue.
Hebrew text 
מה טבו אהליך יעקב, משכנותיך ישראל. (1 Numbers 24:5
ואני ברב חסדך אבוא ביתך אשתחוה אל היכל קדשך ביראתך. (2 Psalms 5:8
Ma tovu ohalekha Ya'akov, mishk'notekha Yisra'el.
Va'ani b'rov hasd'kha, avo veytekha,
Eshtahaveh el heikhal kodsh'kha b'yir'atekha.
Adonai ahavti m'on beitekha, um-kom mishkan k'vodekha.
Va'ani eshtahave v'ekhra'a.
Evr'kha lifnei Adonai osi.
Va'ani t'filati l'kha Adonai et ratzon.
Elohim b'rov hasdekha aneini b'emet yish'ekha.
English translation 
How lovely are your tents, O Jacob, your dwelling places, O Israel!
As for me, O God abounding in grace,
I enter your house to worship with awe in Your sacred place.
I love your house, Eternal One, the dwelling-place of Your glory;
humbly I worship You, humbly I seek blessing from God my Maker.
To You, Eternal One, goes my prayer: may this be a time of your favor.
In Your great love, O God, answer me with Your saving truth.