Since unstressed clitic 'personal pronouns' (‘me/te/le/se/nos/os/los/las/les’) are ‘arguments’ and function as direct or indirect objects (DO, and IO, hereafter) of non-auxiliary verbs, their basic position in Modern Spanish (an SVO language) is, like that of all DOs and IOs, post-verbal (i.e., they are basically 'enclitic'). That is, indeed, where they must appear in two special cases:
The clitic personal pronouns must be post-verbal when a) they are complements of a verb in an infinitival or present participial form (but not if they are complements of an active or passive past participle, see below) and b) the infinitive or present participle occurs on its own (i.e., not preceded by auxiliary verbs), as in e.g., ‘Decírselo [fue un error]’, ‘Diciéndoselo [empeoras las cosas]’.
In such circumstances, it is not possible to shift those ‘enclitics’ to preverbal position and turn them into 'proclitics' (hence, ‘*Se lo decir [fue un error]', '*Se lo diciendo [empeoras las cosas]' are ungrammatical). Neither is it possible to leave one of the enclitics after the verb and move the other one leftwards, as in '*Se decirlo [fue un error]', '*Se diciéndolo [empeoras las cosas]', '*Lo decirse [fue un error]', '*Lo diciéndose [empeoras las cosas]’. The relevant generalization is this: if a clitic complement of V 'moves leftwards', all must do, as an indivisible ‘block’, and preserving their original order.
With the other non-finite forms of the verb, however, i.e., the past participles, the situation is more complicated and we must discuss them separately:
Active past participles (e.g., ‘dicho’ in ‘he dicho’) simply cannot occur on their own; a verb in the active past participle form is necessarily preceded by some form of the auxiliary verb ‘haber’, and any enclitic complements that may initially belong to it must obligatorily be shifted leftwards. However, they are never turned into the past participle’s own proclitics (i.e., the result is never ‘*[haber] se lo dicho’), which would break the rule that personal pronouns cannot be proclitic to non-finite forms of verbs.
Depending on whether the auxiliary ‘haber’ is itself in finite form or not, the result will be different. If ‘haber’ is the first auxiliary (and appears in finite form, say as ‘has’ in 'Tú has'), the original complements of the main verb (‘dicho’, in our example) will be shifted to the left of ‘has’ and turned into its proclitics. Thus, the ‘underlying’ form '*Tú has dichoselo' must eventually surface as ‘Tú se lo has dicho’. However, if ‘haber’ is not itself the first auxiliary and does not occur in finite form, as in the underlying representation '*Tú debías haber dichoselo', the clitic pronouns ‘se+lo’ must be jointly shifted leftwards into either of two positions: a) by default, they must become enclitics of the infinitival form ‘haber’, as in ‘Tú debías habérselo dicho’; or, for some, but not all speakers, b) they can be shifted even further leftwards and turned into proclitics of the finite auxiliary ‘debías’, as in ‘Tú se lo debías haber dicho’. Option b), however, violates the principle of Economy (since option a) is available and more ‘economic’) and is considered ungrammatical or dubious by some speakers (e.g., me).
What is not possible at all is to shift the clitics leftward ‘half-way’ and turn them into proclitics of the non-finite form 'haber', as in ‘*Tú debías se lo haber dicho’, which would violate the rule above that personal pronouns can never be pro-clitic to non-finite verb forms.
Passive past participles, on the contrary, like infinitives and active present participles, can occur on their own. However, when they do, they can take postverbal ‘passive’ subjects (cf. ‘Dicho esto’, not ‘*Esto dicho’) and postverbal indirect objects (cf. ‘Dicho esto a un enfermo terminal’), but, being ‘passive’, they cannot take either postverbal NP direct objects (cf. ‘*Dicho una mentira’) or postverbal enclitic complements of any kind (cf. ‘*Dícholo', ‘*díchome', ‘*díchomelo’, etc.).
In practice, therefore, the only clitic complements of passive past participle verbs are IOs and must appear before a finite auxiliary, as in ‘Le fue retirado el pasaporte’, or ‘Le ha sido retirado el pasaporte’ (but not ‘*Fue retiradole el pasaporte’, ‘*Fue le retirado el pasaporte’, ‘*Fuele retirado el pasaporte’, ‘*Ha sido retiradole el pasaporte’, ‘*Ha sido le retirado el pasaporte’,‘*Ha sidole retirado el pasaporte’, ‘*Hale sido retirado el pasaporte’).
Personal pronouns must be postverbal (i.e., ‘enclitic’) when a) they are DO or IO complements of verbs in the imperative form, and b) the imperative verb is not itself preceded by negation, as in e.g. ‘Díselo’, ‘Decídselo’, ‘Díga(n)selo’. If the imperative verb is preceded by negation, the enclitics must immediately be shifted forward as an indivisible block and turned into proclitics of the imperative verb, as in e.g. ‘No se lo diga/digáis/digan’ (but not ‘*No dígaselo’, ‘*No digáisselo’, ‘*No díganselo’).
The postverbal occurrence of personal pronouns as enclitics after imperative verbs is, nevertheless, exceptional, because imperatives are finite verbs, and when personal pronouns are complements of finite verbs in Modern Spanish they must generally occur before the verb, as in e.g. ‘Se lo dije’ (not ‘*Díjeselo’), as explained below.
The ‘general rule’ with finite forms of the main verb (i.e., when it is inflected for mood, tense, person and number features),is that pronominal DOs or IOs must precede it, as in ‘Se lo dije’ (not ‘*Díjeselo’).
That general rule, however, is unexpected in an SVO language like Modern Spanish, where all complements, including DOs and IOs, must be post-verbal in all other cases, as they indeed are when, instead of unstressed clitic pronouns, the DO or IO are expressed by full noun phrases. For example, in ‘Dije los precios a mis clientes’, the DO and the IO must follow the finite verb (‘*Los precios a mis clientes dije’ is, of course, ungrammatical).
The preverbal occurrence of just unstressed clitic personal pronouns, but not full NPs, is almost certainly a remnant of an earlier stage of Spanish (and Indo-European, in general), in which the canonical word order was SOV, i.e., verb final, as it was in early Latin, Sanskrit, and still is in the subordínate clauses of Modern German. At such a stage, all DOs and IOs, including pronominal ones, preceded the finite verb, although, in some cases, when the DO or IO were pronominal, full NPs were added after the verb in order to clarify their referent. That is attested for early Indoeuropean dialects, and still occurs to some extent in Modern Spanish in sentences with so-called ‘redundant’ or ‘duplicated’ IO clitics, as in ‘Les dije los precios a mis clientes’, where the IO is expressed twice, in full form via the postverbal NP ‘a mis clientes’ and in ‘reduced form’ as the redundant pre-verbal proclitic ‘les’. The only change is that, once Spanish became an SVO language, the verb is no longer clause final and no comma is inserted to mark postverbal complements as detached ‘afterthoughts’ (i.e., as cases of ‘epiphrasis’).
The occurrence of unstressed personal pronouns before finite verbs (and the exceptional SOV order that results only in such cases), however, must nowadays be considered as a ‘derived’ phenomenon, because we have evidence that most preverbal clitics have been ‘displaced’ from postverbal positions. In fact, that must be so whenever the finite verb that immediately follows the personal pronouns is an auxiliary like ‘deber’, ‘poder’, ‘haber’ ‘estar’, etc., because such auxiliary verbs do not take DO or IO complements at all. It follows that any DO or IO clitics that apparently accompany auxiliary verbs, be it as enclitics or as proclitics, must have been displaced from the vicinity of some following non-auxiliary verb in a non-finite form that can take such complements. That phenomenon, technically known as ‘clitic climbing’ is, of course very common, relatively complex, and extremely interesting.
Take typical cases like ‘Te lo han dicho todos los días’, ‘Te lo han estado diciendo todos los días’ ‘Te lo tienen que haber dicho todos los días’, ‘Te lo tienen que estar diciendo todos los días’, ‘Te lo tienen que haber estado diciendo todos los días’, etc., where only the main verb 'decir' can take DO and IO complements.
It follows from what has already been said that the clitics ‘te’ and ‘lo’ must initially appear after the verb ‘decir' whenever its inflectional form allows them to appear there, i.e., when it occurs in the infinitive or present participle form, but not when it is a past participle.
Hence ‘Han estado diciéndotelo todos los días’, ‘Tienen que estar diciéndotelo todos los días’, ‘Tienen que haber estado diciéndotelo todos los días’ must be grammatical, and in fact simpler alternatives than ‘clitic climbing’ cases like ‘Te lo han estado diciendo todos los días’, etc., and so they are, whereas ‘*Han dichotelo todos los días’ and ‘*Tienen que haber dichotelo todos los días’ cannot be well-formed nor possible alternatives to ‘clitic climbing’ solutions like ‘Te lo han dicho todos los días’, etc. (and, indeed, they are not).
An interesting fact about clitic placement in sentences containing auxiliaries, then, is that in some cases (when the verb is an infinitive or a present participle) the clitics can alternatively appear either ‘in situ’, following their verbal head, or ‘displaced’ to the position immediately preceding the finite auxiliary, whereas in others (when the verb is a past participle), the first, and ‘basic’ position is not available (understandably if the participle is passive, as explained above, but mysteriously if it is active, because active participles can generally take DO and IO complements provided they are not enclitic).
However, that alternation by no means exhausts the clitic placement possibilities: when a sentence contains a sequence of auxiliary verbs preceding the main verb, as in ‘Tienen que estar diciéndotelo todos los días’, or ‘Tienen que haber estado diciéndotelo todos los días’, the rules above predict that the clitics ‘te’ ‘lo’ will also be possible in certain intermediate positions, but, crucially, not in others.
Indeed, according to the rule that unstressed personal pronouns can be enclitic to infinitives, ‘te’ and ‘lo’ may also cliticize onto the auxiliary infinitives ‘estar’ or ‘haber’, as in ‘Tienen que habértelo dicho todos los días’, ‘Tienen que habértelo estado diciendo todos los días’, or ‘Tienen que estártelo diciendo todos los días’. On the contrary, the clitics cannot be attached to the past participle ‘estado’, and, indeed, ‘*Han estadotelo diciendo todos los días’, ‘*Tienen que haber estadotelo diciendo todos los días’ are as bad as ‘*Han díchotelo todos los días’ or ‘*Tienen que haber díchotelo todos los días’.
Furthermore, the rules above also prevent personal pronouns from becoming either enclitics to finite auxiliaries or proclitics to non-finite ones. As a consequence ‘*Hántelo dicho todos los días’, ‘*Hántelo estado diciendo todos los días’, ‘*Estántelo diciendo todos los días’, ‘*Tienentelo que haber dicho todos los días’, ‘*Tienentelo que estar diciendo todos los días’, ‘*Tienentelo que haber estado diciendo todos los días’, etc. are all ill-formed for the former reason, whereas ‘*Han te lo dicho todos los días’, ‘*Están te lo diciendo todos los días’, ‘*Han te lo estado diciendo todos los días’, ‘*Han estado te lo diciendo’, ‘*Deben te lo estar diciendo todos los días’, ‘*Deben estar te lo diciendo todos los días’, ‘*Deben haber te lo dicho todos los días’, ‘*Deben haber estado te lo diciendo todos los días’, ‘*Deben haber te lo estado diciendo todos los días’, etc., are all bad for the latter reason.
What precedes is a relatively comprehensive account of the facts, but not yet a real explanation of why the facts are the way they are. ‘Knowledge that’ is not nearly the same as ‘knowledge (of) why’, and some of the crucial facts from which all other facts above follow, and satisfactorily enough, unfortunately remain unexplained. In particular, a) there is, as far as I know, no good explanation of why, in standard Modern Spanish, DO and IO clitics cannot attach themselves to the right of finite verbs, as in ‘*Díjotelo’, whereas, significantly, in my own native dialect (Asturian, spoken in Northern Spain) that construction is the standard one and languages like German allow DOs to attach themselves as enclitics on the right side of finite verbs (cf. ‘Ich gab ’s meinem Vater’); b) there is, to my knowledge, no convincing explanation for the fact that ‘me, te, se, le, lo, les’, etc. should be unable to become proclitics of non-finite verbs, since, again, in other languages, comparable unstressed clitics must precede infinitives and participles (e.g., again, German, where ‘Ich habe es ihm gegeben’, ‘Kannst du es ihm geben?’ are the standard constructions); c) whereas it is clear enough why passive past participles reject enclitic DOs, as far as I know, no explanation has yet been offered for the fact that they should also reject enclitic IOs, or for why active past participles should reject all enclitics, be they DOs or IOs; and finally, d) we still need a cogent explanation for the intriguing fact that IO and DO clitics should be allowed to raise as far leftwards as they do in cases like ‘Te lo tienen que haber dicho’, which is aceptable to some speakers in spite of the fact that there is a more 'economic' solution available, i.e., ‘Tienen que habértelo dicho’; if natural languages are subject to a principle of Economy, clitics should never climb further than strictly necessary, and yet, in such cases they do.