Well, the question is already answered but I will try to explain more details...
Both the game and the NerveGear were created by Akihiko Kayaba.
so we can say the cardinal system and Yui were also created by Akihiko Kayaba.
Yui was programmed to understand and learn human emotions and mental
health but later Yui was locked to just to read and do not have any
access to the system to help people log out in case it is affecting
their health.
while reading everyone mental health she found that there are two
human Kirito and Asuna who were happy and enjoying their life in this
virtual world and everyone else is scared of death and just want to go
out of this shitty game. some of them even lose hope and committed
suicide.
So Yui wants to be part of the Asuna and Kirito. she met them
purposely to go close to them. When they found her they thought she is
just some lost child, they tried to find her parents but later during
a battle in dungeon Yui saved Asuna and kirito ( she was an immortal
object in the game and defeated very high-level monster with ease )
Cardinal was AI software to and is able to recognize that Yui
programmed is having some bug so they decided to delete her. But
kirito plays and smart move and saved her all data in his SAO profile.
Because of Yui Kirito able to understand the reality of Akihiko Kayaba
who was playing a leader role in no.1 clan in the game just to make
people fool ( he was immortal object too that is why kirito loss duel
against him)
later when kirito won sword art he found out 300 people still not
awakened by the game including Asuna. later he found out the image of
Asuna inside another RPG game. He started to play that game in search
Asuna and he found out that the game is having all of his previous
data and skills of sword art online except items. so he tried to find
out Yui data in his profile. after finding her data he activated Yui
back. who read all the information about this game and told him that
this game is having copy data of SAO and turned herself into pixie so
that the game not able to find about her. Yui also told Kirito that
her data is now saved inside local memory of Kirito nervegear.