A group of the Bani Israel who transgressed the prohibitions of the Sabbath were punished by transformation into apes and pigs [for three days, after which they died].
Quran 5:60 Say, "Shall I inform you of [what is] worse than that
as penalty from Allah ? [It is that of] those whom Allah has cursed
and with whom He became angry and made of them apes and pigs and
slaves of Taghut. Those are worse in position and further astray from
the sound way."
Other verses related to the event include 7:163-166. Also see Tafsir Ibn Kathir.
Transformation \ Metamorphosis ( مسخ ) is a form of Divine punishment, and has been Prophesied for a group of Muslims as well (Sahih Bukhari, Book of Drinks):
Prophet (ﷺ) saying, "From among my followers there will be some people
who will consider illegal sexual intercourse, the wearing of silk, the
drinking of alcoholic drinks and the use of musical instruments, as
lawful.
...
Allah will destroy them during the night and will let the mountain
fall on them, and He will transform ( يَمْسَخُ ) the rest of them into monkeys and
pigs and they will remain so till the Day of Resurrection."
Regarding the word "Be", its as explained:
Quran 2:117 Originator of the heavens and the earth. When He
decrees a matter, He only says to it, "Be," and it is. ( كُن فَيَكُونُ )
Quran 16:40 Indeed, Our word to a thing when We intend it is but
that We say to it, "Be," and it is. ( كُن فَيَكُونُ )
A selected narration of the event present in Tafsir Qurtubi on 7:163:
رُوي في قصص هذه الآية أنها كانت في زمن داود عليه السلام
It is narrated that this happened in the time of David.
فقال ابن عباس وعِكرمة والسُّدِّي: هي أيْلة. وعن ٱبن عباس أيضاً أنها
مَدْين بين أيلة والطور. الزُّهْرِيّ: طَبَرِيّة. قتادة وزيد بن أسلم: هي
ساحل من سواحل الشأم، بين مَدْين وعَيْنون، يقال لها: مقناة. .
Ibn Abbas and Akrimah said: It is said that it was in Ila. Narrated
from Ibn Abbas: It was between Ila and Tur. Zuhri said: It was
Tibriyah. Qatatah and Zayed bin Aslam said: It was on a coast on the
coast of Sham (Greater Syria) and is between Aiwan and Midan.
وكان اليهود يكتمون هذه القصة لما فيها من السُّبّة عليهم
The Jews concealed this event because of shame.
Further while on 2:65:
زعم ٱبن رُومان أنهم كانوا يأخذ الرجل منهم خَيْطاً ويضع فيه وَهْقَة
وألقاها في ذَنَب الحوت، وفي الطرف الآخر من الخيط وَتِد وتركه كذلك إلى
الأحد؛ ثم تطرّق الناس حين رأوا مَن صَنَع لا يُبتلَى، حتى كثر صيد الحوت
ومُشِيَ به في الأسواق، وأعلن الفَسَقة بصيده
They thought it permitted to catch fish on the Sabbath. ... One among
them set a trap for the fish ... when the people saw that no calamity
befell him the common people began to do it as well.Until fishing
became common on the Sabbath, and fish was sold in the markets, and
the rebellious ones made an announcement of hunting.
فقامت فرقة فنهت وجاهرت بالنّهي وٱعتزلت. ويقال: إن الناهين قالوا: لا
نساكنكم؛ فقسموا القرية بجدار. فأصبح الناهون ذات يوم في مجالسهم ولم
يخرج من المعتدين أحد؛ فقالوا: إنّ للناس لشأنا؛ فعلَوْا على الجدار
فنظروا فإذا هم قِردة
A group arose, they advised the people to refrain from these
transgressions and seperated themselves. They built a wall to divide
the town.
One day, the ones who had forbidden the transgression were in a
gathering and they noticed that none from the other group had not come
out of their dwellings and they thought something might have happened
to them.
They looked over the wall and saw that the people had been transformed into
monkeys.
ففتحوا الباب ودخلوا عليهم، فعرفت القردة أنسابها من الإنس، ولا يعرف
الإنس أنسابهم من القِردة؛ فجعلت القردة تأتي نسيبها من الإنس فتَشُمّ
ثيابه وتبكي
They opened the gate and went to them ... the monkeys came to their
(untransformed) family members and sniffed their clothes and started
weeping.
فيقول: ألم نَنْهَكم! فتقول برأسها نعم
Then it was said to them: "Weren't you warned?" and they shook their
heads.
قال قتادة: صار الشبان قِردة، والشيوخ خنازير؛ فما نجا إلا الذين نَهَوْا وهلك سائرهم
Qatadah said: The young ones were made into apes and the old ones into
pigs, and the ones who refrained remained human and the ones who were
transformed were destroyed.
...
. قال ٱبن عباس: لم يعش مَسْخٌ قطّ فوق ثلاثة أيام، ولم يأكل ولم يشرب
ولم ينسل
Ibn Abbas said: Those transformed didn't live longer than
three days. Neither did they eat, nor did they drink, nor did their
generations continue.
There is an alternate opinion that they weren't physically transformed, but their hearts were sealed\hardened and "apes" is given as an example of their ignorance. From what I can gather, this is a very minority interpretation and based primarily on reasoning rather than narration.
From Tafsir Al Qurtubi:
ورُوِي عن مجاهد في تفسير هذه الآية أنه إنما مُسِختْ قلوبُهم فقط،
ورُدّت أفهامهم كأفهام القِردة. ولم يقله غيره من المفسرين فيما أعلم.
والله أعلم
Mujahid has narrated in his Tafsir that only their hearts were
transformed and their intellect was made like that of monkeys. As far
as I know this hasn't been said by any other Muffassir. And Allah knows best.
Fakhruddin Razi writes in Tafsir al Kabir:
المسألة الثالثة: المروي عن مجاهد أنه سبحانه وتعالى مسخ قلوبهم بمعنى
الطبع والختم لا أنه مسخ صورهم وهو مثل قوله تعالى: { كَمَثَلِ
ٱلْحِمَارِ يَحْمِلُ أَسْفَاراً } [الجمعة: 5] ونظيره أن يقول الأستاذ
للمتعلم البليد الذي لا ينجح في تعليمه: كن حماراً
Third: Mujahid has narrated that Allah transformed their hearts, as in
put a seal on them, and did not transform their physical bodies. The
exmaple of this is 62:5
And the example of this is that when a teacher says to an extremely
stupid and failing student: "Become a donkey".
Razi then presents the two logical arguments used by Mujahid and gives their counter-arguments and then the counter-counter arguments.