The Misva of Tefilin requires more Kavana (intent) than most Misvot. While all Misvot have a standard Kavana to intend to fulfill the Misva as it is written, the Kavana of Tefilin has an extra dimension. The Torah states that the purpose of Tefilin is: "In order that Hashem’s Torah be in your mouth." The Rabbis derive from here that one must also have this reason in mind when putting on Tefilin.
The Shulhan Aruch in Siman 25 elaborates and details the ideal Kavana of Tefilin: The Tefilin on the arm points to the heart to subjugate its desires, and the Tefilin of the head subjugates the thoughts in the brain to be aligned the way G-d wants us to think. The Tefilin also mention Yesiat Misrayim (the exodus from Egypt), and therefore, one should have that in mind, as well. Remembering the exodus reminds us of the great miracles Hashem performed and reaffirms our belief that God is one and almighty, with supreme control over the upper and lower worlds.
These Kavanot are included in the text of the standard "L’shem Yihud" that is printed before the Berachot. It is good to follow the Ben Ish Hai and say that passage, so that all the Kavanot are included.
B’diavad, after the fact, if one put on Tefilin without this Kavana, he still fulfills the Misva, as long as he intended to fulfill the Misva. However, it is very important to have Kavana when putting on Tefilin, since the purpose of the Misva is to remember. Putting on Tefilin without Kavana is like tying a red string on one’s finger to remind himself of something, but forgetting what he is supposed to remember.
SUMMARY
While putting on Tefilin, one must intend to fulfill the Misva and remember the purpose of the Misva. If he only intended to fulfill the Misva in general, without remembering the purpose, he has still fulfilled the Misva.