How to prove existence of identity function Let $X$ be a non-empty set.Then, how do we show that there is a identity map from $X$ to $X$ using the axioms of set theory?
What you need to understand is the relationship between the axiom of power and the foundation axiom.  In principle, a well-founded model of set theory arises from iterated applications of the power set beginning with the empty set.  Once a set appears as an element, it will occur as a singleton in the next iteration of the power set.  Once a set occurs as a subset, its subsets will occur in the next iteration.  In particular, it pairs will occur.  Since the cumulative hierarchy also uses the axiom of union, the original set elements will be in the same set as these pairs.  So, the next iteration of the power set will form ordered pairs.  Now that you have ordered pairs, another power set iteration will generate sets composed of those ordered pairs, including the relation about which you are asking.  Note that for the identity relation, what would be a pair needs to be a singleton.  But these are generated in the same application of the power set as were the pairs.

Note that the axiom of union is used.  It guarantees that the elements of this account exist.  The same is true of the axiom of pairing.  Since the Cartesian product is, itself, the full relation, it will be composed at the same level as every other relation on the set of interest.  The separation schemes merely guarantee that what you can describe grammatically will exist relative to the sets generated in the cumulative hierarchy.

When you see remarks referring to "enough regularity", one is speaking about the level of the cumulative hierarchy needed to instantiate whatever function or relation is being considered.  However, it is very important to understand how formalist set theory inverts the sense of the constructive account above.  Suppose a particular scheme is asserted.  Then one is already considering models greater than some minimal rank needed to instantiate the scheme.  Formalism is not constructive, although the axiom of foundation is how modern set theory implements something similar to Russell's types.  And, Russell's views had been more along the lines of constructive mathematics.  That is why one can think about matters in this way.

It is true that one can simply prove things in ways suggested in the comments.  However, understanding how an existential claim is witnessed can offer a better picture of how all of the axioms are interrelated.  In other words, what "is" and what "is not" is determined by the cumulative hierarchy.
What you need to understand is the relationship between the axiom of power and the foundation axiom.  In principle, a well-founded model of set theory arises from iterated applications of the power set beginning with the empty set.  Once a set appears as an element, it will occur as a singleton in the next iteration of the power set.  Once a set occurs as a subset, its subsets will occur in the next iteration.  In particular, it pairs will occur.  Since the cumulative hierarchy also uses the axiom of union, the original set elements will be in the same set as these pairs.  So, the next iteration of the power set will form ordered pairs.  Now that you have ordered pairs, another power set iteration will generate sets composed of those ordered pairs, including the relation about which you are asking.  Note that for the identity relation, what would be a pair needs to be a singleton.  But these are generated in the same application of the power set as were the pairs.

Note that the axiom of union is used.  It guarantees that the elements of this account exist.  The same is true of the axiom of pairing.  Since the Cartesian product is, itself, the full relation, it will be composed at the same level as every other relation on the set of interest.  The separation schemes merely guarantee that what you can describe grammatically will exist relative to the sets generated in the cumulative hierarchy.

When you see remarks referring to "enough regularity", one is speaking about the level of the cumulative hierarchy needed to instantiate whatever function or relation is being considered.  However, it is very important to understand how formalist set theory inverts the sense of the constructive account above.  Suppose a particular scheme is asserted.  Then one is already considering models greater than some minimal rank needed to instantiate the scheme.  Formalism is not constructive, although the axiom of foundation is how modern set theory implements something similar to Russell's types.  And, Russell's views had been more along the lines of constructive mathematics.  That is why one can think about matters in this way.

It is true that one can simply prove things in ways suggested in the comments.  However, understanding how an existential claim is witnessed can offer a better picture of how all of the axioms are interrelated.  In other words, what "is" and what "is not" is determined by the cumulative hierarchy.