The Primal Dialga state was from Darkrai's doing who stole the Time Gears, consequently outraging Dialga and disrupting the proper flow of time. In an alternate future, Temporal Tower collapses, sending Dialga into a primal rage, making him a being running on pure primal instinct and self-preservation, thus meaning he'd try to foil any attempt to alter the past to protect himself from being erased from existence. When Grovyle and the player go back in time, Dialga sends his follower Dusknoir back in time as well to stop them. He is not seen up until Dusknoir drags the player and their partner back to the future, where Primal Dialga orders Dusknoir to eliminate them. He then assists his six Sableye in trying to stop the group from going back in time once more but fails due to the partner's quick thinking. Once the player and partner reach the summit of Temporal Tower, the present day Dialga attacks them, believing they've come to destroy the Tower due to being in the process of transforming into Primal Dialga. They manage to defeat him and save the tower, restoring time and Dialga to their normal states after which he thanks the player and their partner, grateful for all they've done. The future Primal Dialga, Grovyle, Dusknoir, and the player are all erased from existence due to being from a future which no longer exists but after the Temporal Tower incident, the present day Dialga returns the player to life as a show of gratitude for repairing the flow of time and the player's sacrifice, as well as the partner's sorrow at the loss of their friend.
However, (revealed in Pokémon Mystery Dungeon: Explorers of Sky), before they are erased from existence, Primal Dialga proceeds to punish Dusknoir for his failure, as well as Grovyle for trying to change the past. However, they escape and eventually it's revealed that it was a plot for Dusknoir to take over Grovyle's body and return to the past to alter it. What Primal Dialga didn't count on was Dusknoir befriending and saving Grovyle. Primal Dialga then battles Grovyle, Dusknoir, and Celebi but is beaten. After time is erased, Primal Dialga, Dusknoir, Grovyle, and Celebi are spared, and Primal Dialga being converted back into normal Dialga in the process. He then informs them they were saved by a being even more powerful than him: implied to be Arceus.
Although Primal Dialga has lost control of its power, it can still warp through time and use its signature move Roar of Time.
The Dialga battled is not actually the same as the one from the future Grovyle comes from, when battled, Dialga still has a shred of its self left, and thus was not completely "primal" yet. This is shown by the future Primal Dialga only able to communicate with a roar (which Dusknoir apparently understands). However, not-quite-Primal Dialga is able to speak to the player and their partner using broken words.