Just because He always does what is perfect does not mean He doesn't have free will in this.
Some sources:
(shaar bechina ch.1):
Since the Creator has free will in whatever He does, is not forced, needs nothing and is not forced by any nature, therefore He created things diverse, according as His wisdom each time dictated; so that the variety shall point to His unity and His free-will in whatever He does, as it is said "Whatsoever the L-ord pleased, has He done in heaven and on earth" (Tehilim 135:6)
Pas Lechem comments there:
"has free will, not forced, etc." - His intent in this is that something which is bound to a nature such as inanimate objects, always do the same thing. But something which acts by will and desire, namely, a human being, which possesses free will - he will have different actions, but not at the same time, rather according to his needs of the time. And the Creator is not bound by any "nature", ch'vch'v, nor is he forced, nor needs anything. The latter two terms "not forced" and "needs nothing" the author wrote to contrast with man. Because a man is sometimes "forced" in his actions, to avoid harm, or he needs to bring some benefit. Therefore, though he acts with free will and desire, one cannot truly call him as doing with "free will", except in a borrowed sense since necessity may prevent him in this. Hence, the term "free will" correctly applies only to G-d, since His will is free of any form of need or necessity, and all the more so of any "nature".
Hence, in the above sense, God has even more free will than us. Also sometimes He completely overrides His attribute of justice (which is truth), as the Ramchal discusses in Kalach Pitchei Chachma, petach #2. Thus He does not always do what is perfect from an absolute truth perspective.
The desire of the Creator is only [to bestow] good. It is impossible to say that the Divine will desired that there could be other forces which can prevent Him [from bestowing good] in any manner whatsoever. Because the Divine will wants solely and exclusively to bestow good, [and if it were the case that other forces could prevent this] then it would certainly not be good that His goodness not be capable of spreading over His creations. And if you ask: "[Perhaps] this is good, namely, the bestowing of good to the righteous and the punishing of the wicked [is good]?" Behold, it is written: "I will have mercy upon whom I will have mercy" (Shemos 33:19), [which was expounded to mean:] "even though he does not deserve it" (Berachos 7a), and it is written: "[In those days, and in that time, says the L-ord,] the iniquity of Israel shall be sought for, and there shall be none; [and the sins of Judah, and they shall not be found: for I will pardon them whom I preserve]" - behold G-d desires to bestow good also to the wicked.