"The relay for the starter is clicking and starter is getting power but no crank...."---Are you sure about that? With the "key messing up" I would suspect the actuator pin or less likely but possibility the ignition switch.
You can pull the starter relay & test to see if the 86 or 85 terminal in that socket gets power when you turn the key to start (one terminal should be grounded*
, the other needs power to close the relay). That will tell you if the ignition switch is sending power to the relay. If not then either the switch is bad or the actuator pin is cracked/broken & not turning the switch to the start position. Either way you have to remove the cylinder/switch. It’s much more common for the pin to break. If you remove the pin you can then turn the switch with a screwdriver & probably start it. If the pin is good & turning the switch doesn’t power the relay, the switch is bad.
If you don’t have a ground at one of the 2 (85 or 86) terminals when in park or neutral, the neutral safety switch is bad (auto trans) or clutch safety switch may be bad (manual). Those need to be grounded (through the PCM) to close the relay when getting power from the key.
Ignition actuator pin
. Check this link for photos & video how-to. Those links are in post #2 Also see post #4 for a potential pitfall when replacing it (if it is broken). You will need a t-10 security bit or break the security pins in the security bolts with a small screwdriver or small punch & use a standard t-10 bit.
2006 lj starting woes
If you want to start it make a short jumper wire, MAKE SURE THE JEEP IS IN NEUTRAL,
pull the relay, & jump between the 30 & 87 terminals. As long as you have power at the 30 terminal (from the fuse #6 in the PDC) that will crank the engine unless the starter is bad. If you turn the key on & jump it, it will start. Just only touch the terminals long enough to start & pull the jumper so you don't damage the starter by having it engaged with the engine running.