All are arguably grammatical, but not all are equally common, or likely to be equally effective.
The most frequent pattern, according to the ‘Longman Student Grammar of Spoken and Written English’ (LSGSWE) is direct object + to-phrase, as in She gave it to him, It was provided to her, I explained it to him, They granted it to her and Will you sell it to me?
She gave him it, It was provided her by the state, They granted her it and Will you sell me it? are on the pattern indirect object + direct object, and this pattern, according to the LSGSWE, occurs almost exclusively in conversation.
She gave it him, I explained it him, They granted it her and Will you sell it me are on a third pattern, direct object + indirect object. This pattern occurs in conversation and fiction, according to the LSGSWE, but is comparatively rare.